home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / bootup / boot_a2m / load_inf / tinystrt.s < prev   
Encoding:
Text File  |  1995-05-02  |  2.6 KB  |  99 lines

  1. *    TINYSTART is written by Klaus Pedersen (micro@imada.dk), and
  2. *    distributed, together with "LOAD_INF".
  3. *   Based on Borland's and Atari's (Ken B.) startup code.
  4.     
  5.                 IMPORT main
  6.  
  7.                 GLOBL _BasPag
  8.                 GLOBL _app
  9.                 GLOBL _PgmSize
  10.                 GLOBL __text, __data, __bss
  11.  
  12.                 GLOBL exit, errno ; these make TC stdio happy!
  13.  
  14. TextStart       EQU $08 
  15. TextSize        EQU $0C 
  16. DataStart       EQU $10 
  17. DataSize        EQU $14
  18. BssStart        EQU $18
  19. BssSize         EQU $1C 
  20. CmdLine         EQU $80
  21.  
  22.  
  23. * Text segment...
  24.                 TEXT
  25.  
  26. __text:         moveq   #0,D1
  27.                 move.l  A0,D0
  28.                 bne.b   NotApp
  29.                 moveq   #1,D1
  30.                 movea.l 4(SP),A0
  31.  
  32. NotApp:         move.l  A0,_BasPag
  33.                 move.w  D1,_app
  34.  
  35. * Calculate program size...
  36.                 movea.l TextSize(A0),A1
  37.                 adda.l  DataSize(A0),A1
  38.                 adda.l  BssSize(A0),A1
  39.                 adda.w  #$100,A1
  40.                 move.l  A1,_PgmSize
  41.  
  42. * Set stack at top of BSS...
  43.                 move.l  A0,D0
  44.                 add.l   A1,D0
  45.                 and.b   #$FC,D0
  46.                 movea.l D0,SP
  47.  
  48. * Make A3 point to Command line...
  49.                 lea     CmdLine(A0),A3
  50.  
  51. * Shrink memory...
  52.                 move.l  A1,-(SP)
  53.                 move.l  A0,-(SP)
  54.                 move.l  #$4A0000,-(SP)
  55.                 trap    #1
  56.                 lea     12(SP),SP
  57.  
  58. * Pass command Line...
  59.                 moveq   #0,D0
  60.                 move.b  (A3)+,D0   ; anything in command-line?
  61.                 beq.b   EmptyCommand
  62.                 clr.b   0(A3,D0.w) ; terminate command-line
  63.                 lea     ArgPointer,A0 ; Argument array (2 long)
  64.                 move.l  A3,4(A0)   ; write address of command line
  65.                 moveq   #2,D0      ; set argc.
  66.  
  67. EmptyCommand:
  68.  
  69. * Execute main program...
  70. *   D0 = argc, if (argc<2) then no parameter(s)...
  71. *   A0 = *argv[2], argv[0] is dummy, argv[1] is a pointer to the command
  72. *        null terminated commandline...
  73. *   In non TURBO_C env. pass these on the stack...
  74.  
  75.                 bsr     main
  76.  
  77. exit:           move.w  D0,-(SP)
  78.                 move.w  #$4C,-(SP)
  79.                 trap    #1
  80.  
  81.  
  82. * Initialized data segment...
  83.                 DATA
  84. __data:
  85.  
  86. errno:          DC.W 0             ; needed to keep stdio happy!
  87.  
  88. * Variable segment...
  89.                 BSS
  90. __bss:
  91.  
  92. _BasPag:        DS.L 1
  93. _PgmSize:       DS.L 1
  94. _app:           DS.W 1
  95.  
  96. ArgPointer:     DS.L 2             ; only 2 args is used (a null and 1.)
  97.  
  98.                 END
  99.